<template>
	<view class="page-container">
    <u-navbar :fixed="false" leftIconSize="0" bgColor="#87ADFF">
      <template #center>
        <view :class="['text-ff']">
          低空科技-执照考题宝典
        </view>
      </template>
    </u-navbar>
       <view class="h-250 bg-primary flex flex-col items-center">
         <image class="rounded-full w-130 h-130 head mt-12" :src="utils.avatar(useStore.userInfo.avatarUrl)" />
		 <view class="mt-30 text-ff font-32" @click="toLogin()">{{ useStore.userInfo.nickName? useStore.userInfo.nickName : '点击登录' }}</view>
	   </view>
	   <view class="px-20">
		<view class="mt-30 bg-ff  rounded-20 box-shadows py-24 px-32">
          <view class="flex justify-between items-center" @click="toExamRecord(0)">
            <view class="flex items-center">
              <image class="icon-52 mr-24" src="/static/images/kaoshijilu.png" />
              <view>模拟考试记录</view>
            </view>
            <image class="w-16 h-24" src="/static/images/right.png" />
          </view>
		  <view class="line"></view>
          <view class="flex justify-between items-center "  @click="toExamRecord(1)">
            <view class="flex items-center">
              <image class="icon-52 mr-24"  src="/static/images/paiming.png" />
              <view>模拟考试排行榜</view>
            </view>
            <image class="w-16 h-24" src="/static/images/right.png" />
          </view>
		  <view class="line"></view>
          <view class="flex justify-between items-center " @click="toExamRecord(2)">
            <view class="flex items-center">
              <image class="icon-52 mr-24"  src="/static/images/about_we.png" />
              <view>关于我们</view>
            </view>
            <image class="w-16 h-24" src="/static/images/right.png" />
          </view>
		  <view class="line"></view>
          <view class="flex justify-between items-center" @click="loginOut">
            <view class="flex items-center">
              <image class="icon-52 mr-24"  src="/static/images/qingli.png" />
              <view>缓存清理</view>
            </view>
            <image class="w-16 h-24" src="/static/images/right.png" />
          </view>
        </view>
	   </view>
	</view>
</template>

<script setup>
import {
	ref
} from 'vue'
import { onShareAppMessage, onLoad } from "@dcloudio/uni-app"
import utils from '@/utils/utils.js'
import {useLogin,checkAudit} from '@/common/useLogin.js'
import useUserStore from '@/store/user.js'
const useStore = useUserStore()
const toExamRecord = (type) => {
  if(!useStore.userInfo.avatarUrl){
    uni.showToast({title: '请先登录',icon: 'none'})
    setTimeout(() => {
      uni.reLaunch({
        url: '/pages/welcome/index'
      })
    }, 1000)
    return
  }
  useLogin((isLogin) => {
    if(type===2){
      uni.showModal({
        title: '关于我们',
        showCancel: false,
      })
    }else{
      uni.navigateTo({
        url: '/pages/my/examRecords/index?type='+type
      })
    }
  })
}
const toLogin =()=>{
  if(!useStore.userInfo.avatarUrl){
    uni.showToast({title: '请先登录',icon: 'none'})
    setTimeout(() => {
      uni.reLaunch({
        url: '/pages/welcome/index'
      })
    }, 1000)
    return
  }
}
//退出登录
const loginOut = () => {
	useStore.logout({})
	uni.showToast({
			title: '清除成功，请重新登录',
			icon: 'none'
		})
	setTimeout(() => {
		uni.reLaunch({
			url: '/pages/welcome/index'
		})
	}, 1000)
}
onShareAppMessage(() => {
	return {
    title: "低空科技-执照考题宝典",
    path: "/pages/my/index",
    imageUrl: utils.imgFormat('/profile/image/bg1.png')
	}
})

</script>

<style lang="scss" scoped>
.head{
	border: 6rpx #ffffff solid;
}
.line{
	height: 1rpx;
	background-color: rgba(230,230,230,0.6);
	margin: 32rpx 0;
}
</style>